/*
 * @Author: your name
 * @Date: 2021-03-12 19:53:15
 * @LastEditTime: 2021-03-20 12:28:27
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \robotc:\Users\hechuan\Desktop\80\vue2_admin_system\src\api\request.js
 */
import axios from 'axios'
import { loginOut } from '@/utils'
const service = axios.create({
    timeout: 5000,
    headers: {
        'Content-type': 'application/json;charset=UTF-8'
    }
})
service.interceptors.request.use(
    config => {
        config.headers['x-song-token'] = sessionStorage.getItem('x-song-token') || ''
        return config
    },
    error => {
        console.log(error)
        return Promise.reject()
    }
)
service.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return response.data
        } else {
            loginOut()
            Promise.reject(response)
        }
    },
    error => {
        return Promise.reject(error)
    }
)

export default service
